---
title: InstantDB
icon: "InstantDB"
---

[InstantDB](https://instantdb.com/) is a simple and powerful database solution that works well with Better Auth UI.

## Prerequisites

Set up your project with the [@daveyplate/better-auth-instantdb](https://github.com/daveyplate/better-auth-instantdb) package.

## Integration with Auth UI Providers

You can pass the InstantDB hooks and mutators to both the `AuthUIProvider` and `AuthUIProviderTanstack` components:

```tsx
import { useInstantAuth } from "@daveyplate/better-auth-instantdb"
import { useInstantOptions } from "@daveyplate/better-auth-ui/instantdb"
import { AuthUIProvider } from "@daveyplate/better-auth-ui"
import { useSession } from "@/lib/auth-client"
import { db } from "@/lib/db"

function Providers({ children }) {
    const { data: sessionData, isPending } = useSession()
    useInstantAuth({ db, sessionData, isPending })
    const { user } = db.useAuth()
    const { hooks, mutators } = useInstantOptions({ 
        db, 
        sessionData, 
        isPending, 
        user, 
        usePlural: true 
    })
    
    return (
        <AuthUIProvider
            // ...other props
            hooks={hooks}
            mutators={mutators}
        >
            {children}
        </AuthUIProvider>
    )
}
```

The same pattern works for `AuthUIProviderTanstack` as well. This is the recommended for use with a Persist Client for offline authentication.